package com.quanyan.financialSystem.web.place;

import com.quanyan.api.APIResponse;
import com.quanyan.common.Plugin.PageObj;
import com.quanyan.financialSystem.entity.vo.place.req.ReqOrderReconciliation;
import com.quanyan.financialSystem.entity.vo.place.req.ReqOrderReconciliationUpdate;
import com.quanyan.financialSystem.entity.vo.place.resp.OrderReconciliationVos;
import com.quanyan.financialSystem.service.place.OrderReconciliationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * OrderReconciliationController
 *
 * @author Tu Chun
 * @date 2016/10/24
 */
@RestController
@RequestMapping(value = "/admin/api/financial/place")
public class OrderReconciliationController {
    private Logger log = LoggerFactory.getLogger(ProfitLossReportFormController.class);
    @Autowired
    private OrderReconciliationService orderReconciliationService;

    @RequestMapping(value = "/orderReconciliation", method = RequestMethod.POST)
    public APIResponse<PageObj<OrderReconciliationVos>> orderReconciliation(@RequestBody ReqOrderReconciliation reqOrderReconciliation) {
        return orderReconciliationService.getOrderReconciliation(reqOrderReconciliation);
    }

    @RequestMapping(value = "/orderReconciliationAll", method = RequestMethod.POST)
    public APIResponse<OrderReconciliationVos> orderReconciliationAll(@RequestBody ReqOrderReconciliation reqOrderReconciliation) {
        return orderReconciliationService.orderReconciliationAll(reqOrderReconciliation);
    }
    @RequestMapping(value = "/updateOrderStatus", method = RequestMethod.POST)
    public APIResponse<?> updateOrderStatus(@RequestBody ReqOrderReconciliationUpdate reqOrderReconciliationUpdate) {
        String placeOrderId=reqOrderReconciliationUpdate.getPlaceOrderId();
        if (placeOrderId == null || "".equals(placeOrderId)) {
            APIResponse.returnFail("订单号不能为空");
        }
        return orderReconciliationService.updateOrderStatus(reqOrderReconciliationUpdate);
    }
}
